package liuch.lock.stopThrowLock;

public class Run {
    public static void main(String[] args) {
        try {
            SyncObject syncObject = new SyncObject();
            StopThrowThread stopThrowLockThread = new StopThrowThread(syncObject, "b", "bb");
            stopThrowLockThread.start();
            /**
             * 线程start之后开始执行syncObject.printObject()方法
             * 给syncObject的name赋值为“b”
             * 然后sleep(2000)
             * 给syncObject的pwd赋值为“bb”,而在这之前当前线程已经执行了stop方法，导致“bb”未赋值成功
             */
            Thread.sleep(100);
            stopThrowLockThread.stop();
            System.out.println(syncObject.getUserName() + " " + syncObject.getPassword());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
